Extract and refactor call formatter - #677
Conversation
| import org.jetbrains.kotlin.psi.psiUtil.startsWithComment | ||
| import org.jetbrains.ktfmt.format.ParseError | ||
|
|
||
| interface CallFormatter : KotlinAstFormatter { |
There was a problem hiding this comment.
Note for the future: please consider spelling explicitly in the commit whether the refactoring (e.g. extraction) is purely mechanical (same code, some names, same comments) or implies some additional non-trivial (e.g. not "moved it from visitX to formatX method") changes.
It will simplify the review process for housekeeping things a lot. Thanks!
| import com.google.googlejavaformat.Indent | ||
| import com.google.googlejavaformat.Output | ||
|
|
||
| sealed class Indentation { |
There was a problem hiding this comment.
Please add a KDoc: an example of what it is and what it represents (I understand it represents an indentation, but what exactly? In some units, as a forced break, or as something to operate on to properly make a GJF decision for block calls? Now to answer that I look into the usages)
| import org.jetbrains.ktfmt.format.visitor.Indentation.Companion.ZERO | ||
| import org.jetbrains.ktfmt.format.visitor.Indentation.Companion.makeCond | ||
|
|
||
| interface CallFormatter : KotlinAstFormatter { |
There was a problem hiding this comment.
Also, a KDoc per our convention, please: what part of grammar it owns, what it formats, etc.
| val blockComments = | ||
| bodyExpression.children().filter { it is PsiComment && it.text.startsWith("/*") }.toList() | ||
|
|
||
| val hasBody = expressionStatements.isNotEmpty() || blockComments.isNotEmpty() |
There was a problem hiding this comment.
// note to self: blockComments only. :120 hasBody considers all comments
|
passing it to @kunyavskiy. Cannot do it manually because of GH orgs shenanigans |
…f `formatFunctionCall`
5497671 to
17f48b5
Compare
Indentationwrappers, mostly to simplify some code. GJF's indents have everything private, so we can't provide customoperator funs for them, requiring us to constantly keep a lot of indent instancesGroupInfointo a separate fileCallFormatter's existing implementationsNote: this PR is purely refactoring, none of the behaviours are changed. I'm planning to extract changes from #634 into a separate
KotlikLangCallFormatterin the next PR